package com.suke.czx.modules.sys.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.suke.czx.common.validate.EnumValue;
import com.suke.czx.common.validate.SysMenuSaveGroup;
import com.suke.czx.common.validate.SysMenuUpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;

/**
 * 应用模块名称: 资源实体
 * 代码描述: 资源实体
 * copyright: AUZAR ALL RIGHTS RESERVED
 * company: AUZAR
 *
 * @author: 颜米晨
 * @date: 2021/08/27 16:31
 */
@Data
@ApiModel(value = "资源管理")
@EqualsAndHashCode(callSuper = true)
public class SysMenu extends Model<SysMenu> implements Serializable {

	@TableId(value = "menu_id", type = IdType.AUTO)
	@ApiModelProperty(value = "资源id")
	@NotNull(groups = {SysMenuUpdateGroup.class}, message = "资源编码不能为空")
	public Long menuId;

	@ApiModelProperty(value = "父资源id，一级资源为0")
	@NotNull(groups = {SysMenuSaveGroup.class, SysMenuUpdateGroup.class}, message = "父资源编码不能为空")
	public Long parentId;

	@ApiModelProperty(value = "父资源名称")
	@TableField(exist = false)
	public String parentName;

	@ApiModelProperty(value = "资源名称")
	@NotNull(groups = {SysMenuSaveGroup.class, SysMenuUpdateGroup.class}, message = "资源名称不能为空")
	public String name;

	@ApiModelProperty(value = "资源URL")
	public String url;

	@ApiModelProperty(value = "授权(多个用逗号分隔，如：user:list,user:create)")
	@NotNull(groups = {SysMenuSaveGroup.class, SysMenuUpdateGroup.class}, message = "资源授权编码不能为空")
	public String perms;

	@ApiModelProperty(value = "类型 0：目录 1：菜单 2：按钮")
	@NotNull(groups = {SysMenuSaveGroup.class, SysMenuUpdateGroup.class}, message = "资源类型不能为空")
	@EnumValue(groups = {SysMenuSaveGroup.class, SysMenuUpdateGroup.class}, intValues = {0, 1, 2}, message = "资源类型只能是0,1,2")
	public Integer type;

	@ApiModelProperty(value = "资源图标")
	public String icon;

	@ApiModelProperty(value = "ztree属性")
	@TableField(exist = false)
	public Boolean open;

	@ApiModelProperty(value = "子资源")
	@TableField(exist = false)
	public List<?> list;

}
